package com.kyzh.core.adapters.v3

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.gushenge.core.beans.IndexTop
import com.kyzh.core.pager.home.HomeFindFragment
import com.kyzh.core.pager.home.HomeGroupChatFragment
import com.kyzh.core.pager.home.HomeOthersFragment
import com.kyzh.core.pager.home.HomeRecomFragment

class HomeTopTabAdapter(val context: Fragment, val titles:ArrayList<IndexTop>): FragmentStateAdapter(context) {
    override fun getItemCount(): Int {
        return titles.size
    }

    override fun createFragment(position: Int): Fragment {
        return when(titles[position].type){
            0 -> HomeFindFragment()
            1 -> HomeRecomFragment()
            5 -> HomeGroupChatFragment()
            else -> HomeOthersFragment.getNewInstance(titles[position])
        }
    }

}